/**
 * 指标管理
 */
import { http } from "@/utils/http";

type ResultTable = {
  total?: number;
  data?: Array<any>;
};

// 指标分页查询
export const pageMeasureList = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", "/account/api/v1/measure/pageMeasureList", { data });
};

// 指标新增
export const createMeasure = (data?: Record<string, any>) => {
  return http.request("post", "/account/api/v1/measure/createMeasure", { data });
};
// 指标新增---点位-根据点位编码获取点位编码&单位
export const getPointCodeAndUnit = (data?: Record<string, any>) => {
  return http.request("post", "/account/api/v1/point/getPointCodeAndUnit", { data });
};
// 指标新增---指标-获取监控实体
export const getMonitorEntity = (data?: Record<string, any>) => {
  return http.request("post", "/account/api/v1/measure/getMonitorEntity", { data });
};
// 指标编辑
export const updateMeasure = (data?: Record<string, any>) => {
  return http.request("post", "/account/api/v1/measure/updateMeasure", { data });
};
// 指标获取详情
export const getMeasure = (data?: Record<string, any>) => {
  return http.request("post", "/account/api/v1/measure/getMeasure", { data });
};
// 指标删除
export const deleteMeasure = (data?: Record<string, any>) => {
  return http.request("post", "/account/api/v1/measure/deleteMeasure", { data });
};
// 指标导入
export const getMeasureImport = (data?: Record<string, any>) => {
  return http.request<Record<string, any>>(
    "post",
    "/account/api/v1/measure/importMeasure",
    {
      data
    },
    {
      headers: {
        "Content-type": "multipart/form-data"
      }
    }
  );
};

// TODO 指标标注标签
export const addMeasureTag = (data?: Record<string, any>) => {
  return http.request("post", "/account/api/v1/measure/saveOrUpdateMeasureTag", { data });
};

// 模糊查询指标
export const searchMeasure = (data?: Record<string, any>) => {
  return http.request("post", "/account/api/v1/measure/queryMeasureLikeCode", { data });
};

// 模糊查询指标-数组
export const searchMeasureArr = (data?: Record<string, any>) => {
  return http.request("post", "/account/api/v1/measure/queryMeasureByCodes", { data });
};
